package cz.czu.pef.DataModelling;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.MappedSuperclass;

@Embeddable
@MappedSuperclass
public abstract class CommonPersistenceObject extends IdPersistenceObject
{
	private static final long serialVersionUID = -1834558622051643598L;

	@Column(length=128, nullable=false, unique=true)
	private String code;
	@Column(length=128, nullable=false)
	private String name;
	@Column(length=1024, nullable=true)
	private String description;
	
	public CommonPersistenceObject(String code, String name, String description)
	{
		super();
		setCode(code);
		setName(name);
		setDescription(description);
	}
		
	public String getName()
	{
		return name;
	}
	
	public void setName(String name)
	{
		this.name = name;
	}
	
	public String getDescription()
	{
		return description;
	}
	
	public void setDescription(String description)
	{
		this.description = description;
	}

	@Override
	public String toString()
	{
		StringBuilder builder = new StringBuilder();
		builder.append("CommonPersistenceObject [name=");
		builder.append(name);
		builder.append(", description=");
		builder.append(description);
		builder.append(", toString()=");
		builder.append(super.toString());
		builder.append("]");
		return builder.toString();
	}

	
	public String getCode()
	{
		return code;
	}

	
	public void setCode(String code)
	{
		this.code = code;
	}
}
